package com.hf.lookatme.zview.adapters;

import android.content.Context;

import com.hf.lookatme.zbean.RegionData;
import com.hf.lookatme.customview.wheel.adapter.AbstractWheelTextAdapter;

import java.util.List;

/**
 * Created by JoeShiguang on 2015/6/10.
 */
public class Adapter_WheelView_WorkLocation extends AbstractWheelTextAdapter {

  private Context context;

  private List<RegionData> list_regions;

  public Adapter_WheelView_WorkLocation(Context context, List<RegionData> list_regions) {
    super(context);
    this.context = context;
    this.list_regions = list_regions;
  }

  public void setList_regions(List<RegionData> list_regions) {
    this.list_regions = list_regions;
  }

  @Override
  protected CharSequence getItemText(int index) {

    if (index >= 0 && index < list_regions.size() && list_regions != null) {
      RegionData item = list_regions.get(index);
      return item.getRegionName();
    }
    return null;
  }

  @Override
  public int getItemsCount() {
    if (list_regions == null || list_regions.size() == 0) {
      return 1;
    }
    return list_regions.size();
  }
}
